package zengyan.view;

import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
import android.widget.EditText;
import android.widget.LinearLayout;

/**
 * Created by ZengYan on 2016/3/27.
 */
public class RightEditView extends LinearLayout {
    private EditText mEdit;
    private AnimCheckBox mCheckBox;
    private int cCount;
    private OnFocusChangeListener mFocusListener;


    public RightEditView(Context context) {
        super(context,null);
    }

    public RightEditView(Context context, AttributeSet attrs) {
        super(context, attrs);


    }
    @Override
    protected void onFinishInflate() {
        super.onFinishInflate();
        cCount = this.getChildCount();
        initViews();
        mEdit.setOnFocusChangeListener(mFocusListener);
        setChecked(true);
    }

    public void setChecked(boolean b) {
        mCheckBox.setChecked(b);
    }

    public interface RightEditViewListener{
        public boolean CheckBoxSetChecked();

    }

    public void setOnFocusChangeListener(OnFocusChangeListener listener){
        mEdit.setOnFocusChangeListener(listener);
    }

    private void initViews( ) {
        Log.d("CancelEditText", "intiView!!!");
        for (int i = 0; i < cCount; i++) {
            View view = getChildAt(i);
            if (view instanceof EditText) {
                mEdit = (EditText) view;
            }
            if (view instanceof AnimCheckBox) {
                mCheckBox = (AnimCheckBox) view;
            }
        }
    }


}


